home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / NDK / NDK_1.3 / Read-Me1.3 / Printer1.3 / Driver.Examples / src / epsonX / dospecial.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-01  |  4.4 KB  |  212 lines

  1. /*
  2.     DoSpecial for EpsonX driver.
  3.     David Berezowski - March/88.
  4. */
  5.  
  6. #include "exec/types.h"
  7. #include "../printer/printer.h"
  8. #include "../printer/prtbase.h"
  9.  
  10. #define LMARG    3
  11. #define RMARG    6
  12. #define MARGLEN    8
  13.  
  14. #define CONDENSED    7
  15. #define PITCH        9
  16. #define QUALITY        17
  17. #define LPI        24
  18. #define INITLEN        26
  19.  
  20. DoSpecial(command, outputBuffer, vline, currentVMI, crlfFlag, Parms)
  21. char outputBuffer[];
  22. UWORD *command;
  23. BYTE *vline;
  24. BYTE *currentVMI;
  25. BYTE *crlfFlag;
  26. UBYTE Parms[];
  27. {
  28.     extern struct PrinterData *PD;
  29.  
  30.     int x = 0, y = 0;
  31.     /*
  32.         00-00    \375    wait
  33.         01-03    \033lL    set left margin
  34.         04-06    \033Qq    set right margin
  35.         07-07    \375    wait
  36.     */
  37.     static char initMarg[MARGLEN] = "\375\033lL\033Qq\375";
  38.     /*
  39.         00-01    \0335        italics off
  40.         02-04    \033-\000    underline off
  41.         05-06    \033F        boldface off
  42.         07-07    \022        cancel condensed mode
  43.         08-09    \033P        select pica (10 cpi)
  44.         10-12    \033W\000    enlarge off
  45.         13-14    \033H        doublestrike off
  46.         15-17    \033x\000    draft
  47.         18-19    \033T        super/sub script off
  48.         20-22    \033p0        proportional off
  49.         23-24    \0332        6 lpi
  50.         25-25    \015        carriage return
  51.     */
  52.     static char initThisPrinter[INITLEN] =
  53. "\0335\033-\000\033F\022\033P\033W\000\033H\033x\000\033T\033p0\0332\015";
  54.     static BYTE ISOcolorTable[10] = {0, 5, 6, 4, 3, 1, 2, 0};
  55.  
  56.     if (*command == aRIN) {
  57.         while (x < INITLEN) {
  58.             outputBuffer[x] = initThisPrinter[x];
  59.             x++;
  60.         }
  61.  
  62.         if (PD->pd_Preferences.PrintQuality == LETTER) {
  63.             outputBuffer[QUALITY] = 1;
  64.         }
  65.  
  66.         *currentVMI = 36; /* assume 1/6 line spacing (36/216 => 1/6) */
  67.         if (PD->pd_Preferences.PrintSpacing == EIGHT_LPI) {
  68.             outputBuffer[LPI] = '0';
  69.             *currentVMI = 27; /* 27/216 => 1/8 */
  70.         }
  71.  
  72.         if (PD->pd_Preferences.PrintPitch == ELITE) {
  73.             outputBuffer[PITCH] = 'M';
  74.         }
  75.         else if (PD->pd_Preferences.PrintPitch == FINE) {
  76.             outputBuffer[CONDENSED] = '\017'; /* condensed */
  77.             outputBuffer[PITCH] = 'P'; /* pica condensed */
  78.         }
  79.  
  80.         Parms[0] = PD->pd_Preferences.PrintLeftMargin;
  81.         Parms[1] = PD->pd_Preferences.PrintRightMargin;
  82.         *command = aSLRM;
  83.     }
  84.  
  85.     if (*command == aCAM) { /* cancel margins */
  86.         y = PD->pd_Preferences.PaperSize == W_TRACTOR ? 136 : 80;
  87.         if (PD->pd_Preferences.PrintPitch == PICA) {
  88.             Parms[1] = (10 * y) / 10;
  89.         }
  90.         else if (PD->pd_Preferences.PrintPitch == ELITE) {
  91.             Parms[1] = (12 * y) / 10;
  92.         }
  93.         else { /* fine */
  94.             Parms[1] = (17 * y) / 10;
  95.         }
  96.         Parms[0] = 1;
  97.         y = 0;
  98.         *command = aSLRM;
  99.     }
  100.  
  101.     if (*command == aSLRM) { /* set left and right margins */
  102.         PD->pd_PWaitEnabled = 253;
  103.         if (Parms[0] == 0) {
  104.             initMarg[LMARG] = 0;
  105.         }
  106.         else {
  107.             initMarg[LMARG] = Parms[0] - 1;
  108.         }
  109.         initMarg[RMARG] = Parms[1];
  110.         while (y < MARGLEN) {
  111.             outputBuffer[x++] = initMarg[y++];
  112.         }
  113.         return(x);
  114.     }
  115.  
  116.     if (*command == aPLU) {
  117.         if (*vline == 0) {
  118.             *vline = 1;
  119.             *command = aSUS2;
  120.             return(0);
  121.         }
  122.         if (*vline < 0) {
  123.             *vline = 0;
  124.             *command = aSUS3;
  125.             return(0);
  126.         }
  127.         return(-1);
  128.     }
  129.  
  130.     if (*command == aPLD) {
  131.         if (*vline == 0) {
  132.             *vline = -1;
  133.             *command = aSUS4;
  134.             return(0);
  135.         }
  136.         if (*vline > 0) {
  137.             *vline = 0;
  138.             *command = aSUS1;
  139.             return(0);
  140.         }
  141.         return(-1);
  142.     }
  143.  
  144.     if (*command == aSUS0) {
  145.         *vline = 0;
  146.     }
  147.     if (*command == aSUS1) {
  148.         *vline = 0;
  149.     }
  150.     if (*command == aSUS2) {
  151.         *vline = 1;
  152.     }
  153.     if (*command == aSUS3) {
  154.         *vline = 0;
  155.     }
  156.     if (*command == aSUS4) {
  157.         *vline = -1;
  158.     }
  159.  
  160.     if (*command == aVERP0) {
  161.         *currentVMI = 27;
  162.     }
  163.  
  164.     if (*command == aVERP1) {
  165.         *currentVMI = 36;
  166.     }
  167.  
  168.     if (*command == aIND) { /* lf */
  169.         outputBuffer[x++] = '\033';
  170.         outputBuffer[x++] = 'J';
  171.         outputBuffer[x++] = *currentVMI;
  172.         return(x);
  173.     }
  174.  
  175.     if (*command == aRI) { /* reverse lf */
  176.         outputBuffer[x++] = '\033';
  177.         outputBuffer[x++] = 'j';
  178.         outputBuffer[x++] = *currentVMI;
  179.         return(x);
  180.     }
  181.  
  182.     if (*command == aSFC) {
  183.         if (Parms[0] == 39) {
  184.             Parms[0] = 30; /* set defaults */
  185.         }
  186.         if (Parms[0] > 37) {
  187.             return(0); /* ni or background color change */
  188.         }
  189.         outputBuffer[x++] = '\033';
  190.         outputBuffer[x++] = 'r';
  191.         outputBuffer[x++] = ISOcolorTable[Parms[0] - 30];
  192.         /*
  193.         Kludge to get this to work on a CBM_MPS-1250  which interprets
  194.         'ESCr' as go into reverse print mode.  The 'ESCt' tells it to
  195.         get out of reverse print mode.  The 'NULL' is ignored by the
  196.         CBM_MPS-1250 and required by all Epson printers as the
  197.         terminator for the 'ESCtNULL' command which means select
  198.         normal char set (which has no effect).
  199.         */
  200.         outputBuffer[x++] = '\033';
  201.         outputBuffer[x++] = 't';
  202.         outputBuffer[x++] = 0;
  203.         return(x);
  204.     }
  205.  
  206.     if (*command == aRIS) {
  207.         PD->pd_PWaitEnabled = 253;
  208.     }
  209.  
  210.     return(0);
  211. }
  212.